/**
 * 给定一个数组，返回它的中序遍历
 * 示例: 输入: [1, 2, 3, 4, 5, 6, 7]
 * 输出: [4, 2, 5, 1, 6, 3, 7]
*/
function inorder (nums) {
    function handler (node, nums) {
        const root = nums[node];
        if (!root) return [];
        return [...handler(2 * node + 1, nums), root, ...handler(2 * node + 2, nums)];
    }
    return handler(0, nums);
}
console.log(inorder([1, 2, 3, 4, 5, 6, 7]));